/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aptech.data;

import aptech.entities.Activity;
import java.util.List;
import org.hibernate.Query;

/**
 *
 * @author home
 */
public class ActivityBO extends ManagerBase<Activity> {

    public ActivityBO() throws Exception {
    }


    public List<Activity> getListByScheduleID(String id) throws Exception {
        beginTransaction();
        String sql = "from Activity a where a.scheduleActivity.scheduleActivityId=:id order by a.dateOfActivity";//convert(datetime, a.dateOfActivity, 103) asc, a.timeDuaration asc";
        Query query = getCurrentSession().createQuery(sql);
        query.setParameter("id", Integer.parseInt(id));
        List<Activity> list = query.list();
        commitAndClose();
        return list;
    }

    public List<Activity> getListByDayAndScheduleID(String id, String day) throws Exception {
        beginTransaction();
        String sql = "from Activity where scheduleActivity.scheduleActivityId=:id and dateOfActivity=:day";
        Query query = getCurrentSession().createQuery(sql);
        query.setParameter("id", Integer.parseInt(id));
        query.setParameter("day", day);
        List<Activity> list = query.list();
        commitAndClose();
        return list;
    }
}
